import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { accessControlInfoVO, accessControlInfoForm, accessControlInfoQuery } from '@/api/access/access-control-info/types';
import { UserInfoVO } from '@/api/access/user/user-info/types';

/**
 * 查询门禁信息列表
 * @param query
 * @returns {*}
 */
export const listaccessControlInfo = (query?: accessControlInfoQuery): AxiosPromise<accessControlInfoVO[]> => {
  return request({
    url: '/access-control/access-control-info/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询门禁信息详细
 * @param accessControlInfoId
 */
export const getaccessControlInfo = (accessControlInfoId: string | number): AxiosPromise<accessControlInfoVO> => {
  return request({
    url: '/access-control/access-control-info/' + accessControlInfoId,
    method: 'get'
  });
};

/**
 * 新增门禁信息
 * @param data
 */
export const addaccessControlInfo = (data: accessControlInfoForm) => {
  return request({
    url: '/access-control/access-control-info',
    method: 'post',
    data: data
  });
};

/**
 * 修改门禁信息
 * @param data
 */
export const updateaccessControlInfo = (data: accessControlInfoForm) => {
  return request({
    url: '/access-control/access-control-info',
    method: 'put',
    data: data
  });
};

/**
 * 删除门禁信息
 * @param accessControlInfoId
 */
export const delaccessControlInfo = (accessControlInfoId: string | number | Array<string | number>) => {
  return request({
    url: '/access-control/access-control-info/' + accessControlInfoId,
    method: 'delete'
  });
};

/**
 * 门禁信息-授权用户列表
 * @param accessControlId
 * @param query
 */
export const grantInfo = (accessControlId: string | number, query?: UserInfoVO) => {
  return request({
    url: '/user/groupAccessControl/grantInfo/' + accessControlId, 
    method: 'get',
    params: query
  });
};